package com.example.shoppingdemo.nslcommodity;

import androidx.appcompat.app.AppCompatActivity;

import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.shoppingdemo.R;
import com.example.shoppingdemo.nslcommodity.IResult.CommodityRs;
import com.example.shoppingdemo.nslcommodity.IResult.ICommodityResult;
import com.example.shoppingdemo.nslcommodity.myview.RoundRectImageView;
import com.example.shoppingdemo.nslcommodity.returnsbean.DemoModel;

public class ReturnsDemo extends AppCompatActivity {
    private ICommodityResult commodityResult;
    private RoundRectImageView icon;
    TextView type,zMoney,title,sku,brand,numder,amount,
            money,reason,describe,time,returnsMoney;
    int id;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_returns_demo);
        id=getIntent().getIntExtra("id",-1);
        commodityResult=new CommodityRs(this);
        initView();
    }
    private void initView(){
        ImageView iback=findViewById(R.id.image_returns_demo_back);
        iback.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        icon=findViewById(R.id.image_order_form_demo_item);
        type=findViewById(R.id.text_demo_type);
        zMoney=findViewById(R.id.demo_zmoney);
        title=findViewById(R.id.text_demo_item_title);
        sku=findViewById(R.id.text_demo_item_sku);
        brand=findViewById(R.id.text_demo_item_brand);
        numder=findViewById(R.id.text_demo_item_numder);
        money=findViewById(R.id.text_demo_item_money);
        reason=findViewById(R.id.text_demo_yuanyin);
        describe=findViewById(R.id.text_demo_describe);
        time=findViewById(R.id.text_demo_time);
        returnsMoney=findViewById(R.id.text_demo_money);
        amount=findViewById(R.id.text_demo_amount);

        commodityResult.onDemo(id, new CommodityRs.onDemoResponse() {
            @Override
            public void onDemoList(DemoModel demoModel) {
                Uri uri=Uri.parse(demoModel.getIcon());
                Glide.with(ReturnsDemo.this).load(uri).into(icon);
              switch (demoModel.getType()){
                  case 0:
                      type.setText("待处理");
                      break;
                  case 1:
                      type.setText("退货中");
                      break;
                  case 2:
                      type.setText("退货成功");
                      break;
                  case 3:
                      type.setText("退货失败");
                      break;
              }
                zMoney.setText("￥"+demoModel.getzMoney());
                title.setText(demoModel.getTitle());
                sku.setText(demoModel.getSku());
                brand.setText("品牌："+demoModel.getBrand());
                numder.setText("X"+demoModel.getNumder());
                money.setText("￥"+demoModel.getMoney());
                reason.setText(demoModel.getReason());
                describe.setText(demoModel.getDescribe());
                time.setText(demoModel.getTime());
                returnsMoney.setText("￥"+demoModel.getzMoney());
                amount.setText(""+demoModel.getNumder());
            }
        });
    }
}